/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.femass.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;


@Entity
@Table(name = "Aluno")
@NamedQueries({
    @NamedQuery(name = "Aluno.findAll", query = "SELECT a FROM Aluno a"),
    @NamedQuery(name = "Aluno.findByMatricula", query = "SELECT a FROM Aluno a WHERE a.matricula = :matricula"),
    @NamedQuery(name = "Aluno.findByParticipantecod", query = "SELECT a FROM Aluno a WHERE a.participantecod = :participantecod")})
public class Aluno implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Column(name = "matricula")
    private int matricula;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "Participante_cod")
    private Integer participantecod;
    @JoinColumn(name = "Participante_cod", referencedColumnName = "cod", insertable = true, updatable = false)
    @OneToOne(optional = false)
    private Participante participante;

    public Aluno() {
    }

    public Aluno(Integer participantecod) {
        this.participantecod = participantecod;
    }

    public Aluno(Integer participantecod, int matricula) {
        this.participantecod = participantecod;
        this.matricula = matricula;
    }

    public int getMatricula() {
        return matricula;
    }

    public void setMatricula(int matricula) {
        this.matricula = matricula;
    }

    public Integer getParticipantecod() {
        return participantecod;
    }

    public void setParticipantecod(Integer participantecod) {
        this.participantecod = participantecod;
    }

    public Participante getParticipante() {
        return participante;
    }

    public void setParticipante(Participante participante) {
        this.participante = participante;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (participantecod != null ? participantecod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Aluno)) {
            return false;
        }
        Aluno other = (Aluno) object;
        if ((this.participantecod == null && other.participantecod != null) || (this.participantecod != null && !this.participantecod.equals(other.participantecod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.femass.model.Aluno[ participantecod=" + participantecod + " ]";
    }

}
